Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Select Multiple File attachments and show it in the list"
Bootstrap 4.1.1 Snippet by
Ranjith Ramesh
4.1.1
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
2.0K
 
0 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!-- self sevice application starts --> <div class="drag-upload-file"> <div class="container"> <div class="row"> <div class="col-sm-5"> <h3>Attachments</h3> </div> <div class="col-sm-7"> <div class="file-upload"> <div class="fields-details"> <input type="file" multiple id="myFile" name="img" onChange="myFunction()"/> <h4><i class="fa fa-file"></i><span>Drop file here or click to upload</span></h4> </div> </div> <div class="attachements"> <div class="items"> <div class="details" id="list"> <a href=""><i class="fa fa-close"></i></a> </div> </div> <!-- items ends --> </div> </div> </div> </div> </div> <!-- self sevice application ends -->
/* drag-upload-file starts */ .drag-upload-file{ width:100%; float:left; padding: 60px 0; background: #fff; } .drag-upload-file h4{ border:0px; } .drag-upload-file h3{ text-align: right; } .drag-upload-file .file-upload{ width:100%; float:left; } .drag-upload-file .fields-details{ border: 1px solid #cacaca; border-radius: 8px; background: #fbfbfb; text-align: center; position: relative; } .drag-upload-file .fields-details input[type="file"]{ width: 100%; height: 76px; background: #fbfbfb; opacity: 0; text-align: center; z-index: 999; } .drag-upload-file .fields-details h4{ border: 0px; width: auto; margin: 0 auto; display: block; position: absolute; top: 16px; right: 0; left: 0; } .drag-upload-file .attachements{ width: 100%; float: left; margin-top: 20px; } .drag-upload-file .fields-details i{ background: #fff; border-radius: 50%; border: 1px solid #a3a3a3; height: 40px; width:40px; line-height: 38px; margin-right: 10px; } .drag-upload-file .attachements{ width: 100%; float: left; margin-top: 20px; position: relative; } .drag-upload-file .items{ padding: 10px; background: #d5fffb; border: 1px solid #00ebd5; margin-bottom: 20px; position: relative; } .drag-upload-file .items i{ position: absolute; top: 11px; right: 16px; } /* drag-upload-file ends */
const arr = []; function myFunction() { var x = document.getElementById("myFile").files; arr.push(x[0]); var convertList = []; for(var i= 0; i< arr.length; i++){ console.log(arr[i].name) convertList.push("<div>" + arr[i].name + "</div>"); } document.getElementById("list").innerHTML = convertList.join("") }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76